//
//  UIBarButtonItemExtension.swift
//  edu
//
//  Created by karlzhou on 15/12/10.
//  Copyright © 2015年 karlzhou. All rights reserved.
//

import Foundation
extension UIBarButtonItem{
    
    public static func itemWithImage(image:String, highImage:String , target:AnyObject , action:Selector) -> UIBarButtonItem
    {
        let btn = UIButton()
        btn.setBackgroundImage(UIImage(named: image), forState:.Normal)
        btn.setBackgroundImage(UIImage(named: highImage), forState:.Highlighted)
        let currentImage = btn.currentBackgroundImage
        if(currentImage != nil){
            btn.size = (currentImage?.size)!

        }
               btn.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        return UIBarButtonItem(customView: btn)
    }

    
}